package com.okami.domain.onlineshop;

import com.okami.common.AbstractEntity;
import com.okami.domain.onlineshop.converter.MapStringConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.FactoryBean;

import javax.persistence.*;
import java.util.Map;

/**
 * @author: TanJingyu
 * @create: 2020-12-22 14:55
 **/
@EqualsAndHashCode(callSuper = true, exclude = "goods")
@Data
@Entity
@Table
@Accessors(chain = true)
@ToString(exclude = "goods")
public class Sku extends AbstractEntity<Long> {

    @Convert(converter = MapStringConverter.class)
    private Map<String, String> specifications;
    private Integer stock;
    private Long price;

    @ManyToOne
    @JoinTable(name = "goods_sku", joinColumns = {@JoinColumn(name = "sku_id", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "goods_id", referencedColumnName = "id")})
    private Goods goods;
}
